<div class="headlabel"><?php echo $this->__("ORDER HISTORY") ?></div>
<div class="build-order">
<h4><?php echo $this->__("PRODUCTS") ?></h4>
<p style="padding-left:10px;"><?php echo $this->__("Use itemized order form below to quickly add items to your cart") ?></p>
<p class="lblorder"><span><?php echo $this->__("Qty") ?></span><span><?php echo $this->__("NBS Item #") ?></span></p>

<form action="<?php echo $this->getUrl('checkout/cart/addmultiple') ?>" method="post" id="build_order_form">
<ul>
  
        <li id="build_your_order">
            <div class="order-items">
                <div class="qty">
                    <input type="text"  class="quantity" name=""  value="1"/>
                    <input type="text" 	class="nbs sku" name="sku" />
                </div>
            </div>
            <div class="order-items">
                <div class="qty">
                    <input type="text"  class="quantity" name="qty"  value="1"/>
                    <input type="text" 	class="nbs sku" name="sku" />
                </div>
            </div>
            <div class="order-items">
                <div class="qty">
                    <input type="text"  class="quantity" name="qty"  value="1"/>
                    <input type="text" 	class="nbs sku" name="sku" />
                </div>
            </div>
            <div class="order-items">
                <div class="qty">
                    <input type="text"  class="quantity" name="qty"  value="1"/>
                    <input type="text" 	class="nbs sku" name="sku" />
                </div>
            </div>
            <div class="order-items">
                <div class="qty">
                    <input type="text"  class="quantity" name="qty"  value="1"/>
                    <input type="text" 	class="nbs sku" name="sku" />
                </div>
            </div>
            <div class="order-items">
                <div class="qty">
                    <input type="text"  class="quantity" name="qty"  value="1"/>
                    <input type="text" 	class="nbs sku" name="sku" />
                </div>
            </div>
        </li>
</ul>
<div class="data_add_more" style="display:none">
    <div class="order-items">
        <div class="qty">
            <input type="text"  class="quantity" name=""  value="1"/>
            <input type="text" 	class="nbs sku" name="sku" />
        </div>
    </div>
    <div class="order-items">
        <div class="qty">
            <input type="text"  class="quantity" name="qty"  value="1"/>
            <input type="text" 	class="nbs sku" name="sku" />
        </div>
    </div>
    <div class="order-items">
        <div class="qty">
            <input type="text"  class="quantity" name="qty"  value="1"/>
            <input type="text" 	class="nbs sku" name="sku" />
        </div>
    </div>
</div>
<div class="build-add-to-cart">
    <a class="add-to-cart"><?php echo $this->__("Add To Cart") ?></a>
</div>
<div class="add-more">
    <a href="javascript:void(0)" class="add_more_input"><?php echo $this->__("Show more entry fields") ?></a>
</div>
</form>
</div>
<input type="hidden" value="<?php echo $this->getUrl("home/order/build") ?>" id="#home_build" />
<script type="text/javascript">
    
    jQuery(document).ready(function(){
        jQuery('a.add-to-cart').unbind('click').click(function(){
            jQuery("#build_order_form").submit();
        });
        jQuery('.sku').unbind('blur').blur(function() {
            
            jQuery(".sku").unbind('change').change(function() {
                var sku = jQuery(this).val();
                getProductInfo(sku,this);
            });
            
        });
        jQuery('.sku').blur();
        jQuery('.add_more_input').unbind('click').click(function(e) {
            //alert(jQuery(".data_add_more").());
            jQuery("#build_your_order").append(jQuery(".data_add_more").html());
        });
        
        /*
        jQuery('.quantity').bind('blur', function() {
            var sku = jQuery(this).siblings(".sku");
            getProductInfo(sku,".sku");
        });*/

        
    });
    function getProductInfo(sku,element){

        var url_home_build = jQuery("#home_build").val();
        var object = jQuery(element).parents(".order-items").first();
        jQuery.ajax({
            type : 'POST',
            dataType : 'json',
            url : url_home_build,
            data: {sku:sku},
            beforeSend:function() {
                jQuery(element).parents(".order-items").find(".info").remove();
                jQuery(element).parents(".order-items").find(".price-items").remove();
                jQuery(element).parents(".order-items").first().append('<div class="info invalid">Loading...</div>');
            },
            success : function(data) {
                if(data.error == 1 ){
                    alert(data.message);
                    //jQuery(element).parents(".order-items").first().find(".loading").remove();
                }
                else{
                    object.empty();
                    object.append(data.result);
                   
                    jQuery('.sku').unbind('blur').blur(function() {

                        jQuery(".sku").unbind('change').change(function() {
                            var sku = jQuery(this).val();
                            getProductInfo(sku,this);
                        });
                    });
                    jQuery('.sku').blur();
                }
            }
        });
    } 
</script>